/*
 * @Author: xujianxing
 * @Date: 2020-03-06 18:59:50
 * @LastEditors: xujianxing
 * @LastEditTime: 2020-03-15 11:15:55
 * @Description: file content
 */
import { request } from "./config";

/**
 * 
 * @param {String} ids 多个歌曲的id 23432，23424，2342
 */
export const getSongDetail = ids => request('/song/detail',{ids})

/** 获取歌曲URL id = 12321443,123114 多个用逗号隔开 */
export const getSongUrl = id => request('/song/url',{id})
/**
 * 歌曲评论
 * @param {String} id 歌曲ID
 * @param {Number} limit 每页数目
 * @param {Number} offset 页数
 */
export const getSongComment = (id,limit=20,offset=0) => request('/comment/music',{id,limit,offset})

/** 歌词 */
export const getLyric = id => request('/lyric',{id})

/** 首页最新音乐 */
export const getNewMusic = () => request("/personalized/newsong");

/** 首页推荐歌单 */
export const getRemdSongList = (limit = 30) => request('/personalized',{limit})

/** 歌单详情 */
export const songListDetail = id => request('/playlist/detail',{id})

/**
 * 歌单评论
 * @param {String} id 歌单IDL
 * @param {Number} offset 页数
 * @param {Number} limit 每页数目
 */
export const getListComment = (id,offset = 0,limit = 30) => request('comment/playlist',{id,limit,offset})

/** 热歌榜 idx=1 */
export const getHotBang = (idx = 1) => request('/top/list',{idx})

/**
 * 搜索接口
 * @param {String} keywords 关键词
 * @param {Number} offset 页数
 * @param {Number} limit 每页多少记录默认30
 * @param {Number} type 搜索类型，1为歌曲
 */
export const search = (keywords,offset,limit=30,type=1) => request('/search',{keywords,limit,type,offset})

/** 热搜词 */
export const hotWords = () => request('/search/hot')

/**
 * 
 * @param {String}} keywords 关键字
 * @param {String?} type 默认移动端  'mobile' or 'pc'
 */
export const suggestWords = (keywords,type="mobile") => request('/search/suggest',{keywords,type})

/**
 * 多重匹配
 * @param {String} keywords 关键字
 */
export const getMatchList = (keywords) => request('/search/multimatch?keywords='+keywords)


/**
 * 获得热门评论
 * 
 * @param {Number} id 资源id
 * @param {Number} type 资源类型
 * @param {Number} offset 偏移 （当前页数-1）*limit 
 * 0: 歌曲

1: mv

2: 歌单

3: 专辑

4: 电台

5: 视频
 */
export const getHotComment = (id,type,offset) => request(`/comment/hot?id=${id}&type=${type}&offset=${offset}`)